using System;
using System.Collections.Generic;
using BLToolkit.Data;
using BLToolkit.DataAccess;
using dbvc.data;

namespace dbvc.context
{
    public static class ActivityQuery
    {
        public static IList<db_activity> GetAllActivities()
        {
            using(var db = new DbManager())
            {
                var query = new SqlQuery<db_activity>();
                return query.SelectAll(db);
            }
        }

        public static void CreateActivity(db_activity activity)
        {
            using (var db = new DbManager())
            {
                var query = new SqlQuery<db_activity>();
                query.Insert(db, activity);
            }
        }

        public static void DeleteActivity(db_activity activity)
        {
            using (var db = new DbManager())
            {
                var query = new SqlQuery<db_activity>(db);
                query.Delete(db, activity);
            }
        }

        public static int GetCount()
        {
            using (var db = new DbManager())
            {
                return db.SetCommand("SELECT COUNT(*) FROM db_activity").ExecuteScalar<int>();
            }
        }
    }
}